package kr.saeildamil.androidStudy_second.actionbar;

import kr.saeildamil.androidStudy_second.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.ShareActionProvider;
import android.widget.TextView;

public class ShareActionProviderTest extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		TextView text = new TextView(this);
		text.setText("공유 액션 프로바이더를 테스트합니다.");
		setContentView(text);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		 super.onCreateOptionsMenu(menu);
		 MenuInflater inflater = getMenuInflater();
		 inflater.inflate(R.menu.shareactionmenu, menu);
		 
		 Intent intent = new Intent(Intent.ACTION_SEND);
		 intent.setType("text/plain");
		 intent.putExtra(Intent.EXTRA_TEXT, "Sharing Text");
		 
		 MenuItem share = menu.findItem(R.id.ch21_shareactionmenu_share);
		 ShareActionProvider provider = (ShareActionProvider) share.getActionProvider();
		 provider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
		 provider.setShareIntent(intent);
		 
		 MenuItem sharemenu = menu.findItem(R.id.ch21_shareactionmenu_sharemenu);
		 ShareActionProvider sharemenu1 = (ShareActionProvider) share.getActionProvider();
		 sharemenu1.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
		 sharemenu1.setShareIntent(intent);
		 
		 return true;
		 
	}
}
